<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="mainMenu" />
<meta name="nav" content="0" />
<meta name="acc" content="2" />
<title>部门管理</title>
<script>
	$(document).ready(function() {
		//聚焦第一个输入框
		$("#depCode").focus();
		//为inputForm注册validate函数
		$("#inputForm").validate({
			rules:{
				depCode:{
					required:true,
					remote:"department!checkDepCode.action?oldDepCode=" + encodeURIComponent('${depCode}')
				},
				depName:"required",
				burderMan:"required",
				depType:"required",
				contactTelephone:"digits",
				portraiture:"digits",
				staffers:"digits"
			},
			messages:{
				depCode:{
					remote:"<font color='red'>机构代码已存在</font>"
				}
			}
		});
	});
	function changeExternalOrgName() {
		var orgId = $("input[name='orgId']").val();
		var url = "";
		if (orgId) {
			url = "<c:url value='/account/api/external_organization.action?id='/>"
					+ orgId;
		} else {
			url = "<c:url value='/account/api/external_organization.action'/>"
		}
		var obj = new Object();
		mm = window
				.showModalDialog(
						url,
						obj,
						'dialogHeight:500px;dialogWidth:780px;status:no;toolbar:no;resizable:no;menubar:no;location:no;scrollbars:no;dialogLeft:'
								+ (screen.width / 2.0 - 150) + ',dialogTop:170')
		if (mm != null) {
			$("input[name='orgId']").val(mm.id);
			$("input[name='orgName']").val(mm.orgName);
		}
	}
	function changeInsideOrgName() {
		var orgId = $("input[name='orgId']").val();
		var url = "";
		if (orgId) {
			url = "<c:url value='/account/api/inside_organization.action?id='/>"
					+ orgId;
		} else {
			url = "<c:url value='/account/api/inside_organization.action'/>"
		}
		var obj = new Object();
		mm = window
				.showModalDialog(
						url,
						obj,
						'dialogHeight:500px;dialogWidth:780px;status:no;toolbar:no;resizable:no;menubar:no;location:no;scrollbars:no;dialogLeft:'
								+ (screen.width / 2.0 - 150) + ',dialogTop:170')
		if (mm != null) {
			$("input[name='orgId']").val(mm.id);
			$("input[name='orgName']").val(mm.orgName);
		}
	}
</script>
</head>
<body>
	<form action="department!save.action" method="post"  class="yform" id="inputForm">
		<div id="caption"><h6><s:if test="id == null">创建</s:if><s:else>修改</s:else>部门</h6></div>
		<input type="hidden" name="id" value="${id}" />
		<input type="hidden" name="organizationId" value="${organizationId}" />
		
		<c:if test="${fn:length(id)==0}">
			<input type="hidden" name="org.id" value="${param.organizationId}"/>
		</c:if>	
		<c:if test="${fn:length(id)!=0}">
			<input type="hidden" name="org.id" value="${organization.id}"/>
		</c:if>	
		<table class="noborder">
			<tr class="type-text">
				<td>机构代码</td>
				<td><input type="text" id="depCode" name="depCode"
					value="${depCode}" class="required" /></td>
				<td>部门名称</td>
				<td><input type="text" id="depName" name="depName"
					value="${depName}" class="required" /></td>
			</tr>
			<tr class="type-text">
				<td>部门全称</td>
				<td colspan="3"><input type="text" id="depAllName"
					name="depAllName" class="required" value="${depAllName }" />
				</td>
			</tr>
			<tr class="type-text">
				<td>主要负责人</td>
				<td><input type="text" name="burderMan" id="burderMan"
					value="${burderMan }" class="required" />
				</td>
				<td>机构类别</td>
				<td>
				<s:select list="{'部门','机构'}" name="depType"></s:select>	
				</td>
			</tr>
			<tr class="type-text">
				<td>联系人</td>
				<td><input type="text" id="contactMan" name="contactMan"
					value="${contactMan }" class="required" />
				</td>
				<td>联系电话</td>
				<td><input type="text" id="contactTelephone"
					name="contactTelephone" value="${contactTelephone }"
					class="required" />
				</td>
			</tr>
			<tr class="type-text">
				<td>传真</td>
				<td><input type="text" id="portraiture" name="portraiture"
					value="${portraiture}" class="required" />
				</td>
				<td>职员人数</td>
				<td><input type="text" id="staffers" name="staffers"
					value="${staffers}" class="required" />
				</td>
			</tr>
			<tr class="type-text">
				<td>职能描述</td>
				<td colspan="3"><textarea id="functionDesc" name="functionDesc">${functionDesc }</textarea>
				</td>
			</tr>
			<tr class="type-text">
				<td>备注</td>
				<td colspan="3"><textarea id="remark" name="remark">${remark}</textarea></td>
			</tr>
		</table>
						<div class="type-button">
						<input   type="submit" class="submit" value="提交" />&nbsp;
						<input   type="button" value="返回" class="reset"
							onclick="history.back()" />
					</div>
	</form>
</body>
</html>